import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By


class TestLogin:
    def setup_method(self):
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.implicitly_wait(3)

    def teardown_method(self):
        self.driver.quit()

    def test_login(self):
        self.driver.get('https://ceshiren.com/')
        self.driver.find_element(By.XPATH, "//span[@class='d-button-label' and text()='登录']").click()
        self.driver.find_element(By.XPATH, '//input[@type="email"]').send_keys('saberpan')
        self.driver.find_element(By.XPATH, '//input[@type="password"]').send_keys('ym19960214')
        self.driver.find_element(By.XPATH, '//div[@class="modal-footer"]/button').click()
        # 断言主页没找到合适的方法，所以进入个人详情
        self.driver.find_element(By.XPATH, '//a[@title="潘修琦"]').click()
        self.driver.find_element(By.XPATH, '//button[@title="通知"]').click()
        name = self.driver.find_element(By.XPATH, '//h2[@class="full-name"]').text
        assert name == '潘修琦'
